//
//  HZMLeadVC.m
//  糖糖大魔王
//
//  Created by 韩震明 on 15/11/9.
//  Copyright © 2015年 韩震明. All rights reserved.
//
#import "AppDelegate.h"
#import "HZMLeadVC.h"
#define WIDTH self.view.frame.size.width
#define HEIGHT self.view.frame.size.height

@interface HZMLeadVC ()<UIScrollViewDelegate,UIGestureRecognizerDelegate>

@property(nonatomic, retain) UIScrollView *scrollView;

@end

@implementation HZMLeadVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setScrollView];
    
}



#pragma - mark set ScrollView
- (void)setScrollView
{
    self.scrollView = [[UIScrollView alloc] initWithFrame:self.view.frame];
    [self.view addSubview:self.scrollView];
    [_scrollView release];
    self.scrollView.showsHorizontalScrollIndicator = NO;
    self.scrollView.contentSize = CGSizeMake(3 * self.view.frame.size.width, 0);
    [self setImageView];
    self.scrollView.pagingEnabled = YES;
    self.scrollView.bounces = NO;
    self.scrollView.contentOffset = CGPointMake(WIDTH, 0);
}

#pragma mark ScrollViewData
- (void)setImageView
{
    
    for (NSInteger i = 0; i < 3 ; i++) {
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * WIDTH, 0, WIDTH, HEIGHT)];
        imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"girl%ld.pdf", i]];
        [self.scrollView addSubview:imageView];
        [imageView release];
        imageView.userInteractionEnabled = YES;
        imageView.tag = 1001 + i;
        
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick:)];
        [imageView addGestureRecognizer:tap];
        [tap release];
        tap.delegate = self;
    }
}

- (void)tapClick:(UITapGestureRecognizer *)tap
{
    AppDelegate *appVC = (AppDelegate *)[[UIApplication sharedApplication]delegate];
    [[UIApplication sharedApplication].keyWindow setRootViewController:appVC.tab];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
